package DControl;

import java.awt.event.MouseEvent;

public class DApplication{
	
	String name = "δ֪",sex = "δ֪",age = "δ֪",marriage = "δ֪",health = "δ֪";
	DFrame frame1,frame2,frame3,frame4,frame5,frame6;
	int index;
	DRadioGroup group,group_fj,group_f,group_j;
	DTextField tfd,tfd1,tfd2;
	
	
	
	public DApplication()
	{
		DLabel label = new DLabel(105,100,"������Ϣ����¼");
		DButton btn = new DButton(70,250,"ȷ��");
		DButton btn1 = new DButton(160,250,"ȡ��");
		
		group = new DRadioGroup();
		DRadio radio = new DRadio(100,140,"������Ϣ����");
		DRadio radio1 = new DRadio(100,180,"��˽��Ϣ����");
		//radio.setSelect(true);		
		
		group.addControl(radio);
		group.addControl(radio1);
		
		index = group.getIndex();
		
		frame1 = new DFrame();
		frame1.addControl(label);
		frame1.addControl(btn);
		frame1.addControl(btn1);
		frame1.addControl(radio);
		frame1.addControl(radio1);
		
		radio.addDMouseListener(new doRadio1());
		radio1.addDMouseListener(new doRadio2());
		btn.addDMouseListener(new doMouse1());
		btn1.addDMouseListener(new doMouse2());
		
		
		frame1.setSize(300,400);
		frame1.setLocation(500, 100);
		frame1.setVisible(true);
		
	}
	
	public class doRadio1 extends DMouseAdapter{
		public void mousePressed(MouseEvent e)
		{
			index = group.getIndex();
		}
	}
	
	public class doRadio2 extends DMouseAdapter{
		public void mousePressed(MouseEvent e)
		{
			index = group.getIndex();
		}
	}
	
	public class doMouse1 extends DMouseAdapter{
		
		public void mousePressed(MouseEvent e)
		{
			frame1.setVisible(false);
			if(index == 0)
			{
				System.out.println("yes");
				
				DLabel label = new DLabel(50,100,"����");
				DLabel label1 = new DLabel(50,150,"�Ա�: ");
				DLabel label2 = new DLabel(50,200,"����: ");
				
				tfd = new DTextField(120,100-10,12);
				tfd1 = new DTextField(120,150-10,12);
				tfd2 = new DTextField(120,200-10,12);
				
				DButton btna = new DButton(70,250,"ȷ��");
				DButton btnb = new DButton(160,250,"ȡ��");
				
				frame2 = new DFrame();
				frame2.addControl(label);
				frame2.addControl(label1);
				frame2.addControl(label2);
				frame2.addControl(tfd);
				frame2.addControl(tfd1);
				frame2.addControl(tfd2);
				frame2.addControl(btna);
				frame2.addControl(btnb);
				
				btna.addDMouseListener(new doMousea());
				btnb.addDMouseListener(new doMouseb());
				
				frame2.setSize(300,400);
				frame2.setLocation(500, 100);
				frame2.setVisible(true);
			}
			else 
			{
				System.out.println("Cancle");
				
				group_fj = new DRadioGroup();
				DRadio radiof = new DRadio(100,140,"����״��");
				//radiof.setSelect(true);
				DRadio radioj = new DRadio(100,180,"����״��");
				
				group_fj.addControl(radiof);
				group_fj.addControl(radioj);
				
				index = group_fj.getIndex();
				
				DButton btnf = new DButton(70,250,"ȷ��");
				DButton btnj = new DButton(160,250,"ȡ��");
				
				frame3 = new DFrame();
				frame3.addControl(radiof);
				frame3.addControl(radioj);
				frame3.addControl(btnf);
				frame3.addControl(btnj);
				
				radiof.addDMouseListener(new doMousef());
				radioj.addDMouseListener(new doMousej());
				btnf.addDMouseListener(new doMousef_btn());
				btnj.addDMouseListener(new doMousej_btn());
				
				frame3.setSize(300,400);
				frame3.setLocation(500, 100);
				frame3.setVisible(true);
			}
			
		}
		
		public class doMousea extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				name = tfd.text;
				sex = tfd1.text;
				age = tfd2.text;
				
				frame2.setVisible(false);
				frame1.setVisible(true);
			}
		}
		
		public class doMouseb extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				frame2.setVisible(false);
				frame1.setVisible(true);
			}
		}
		
		public class doMousef extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				index = group_fj.getIndex();
			}
		}
		
		public class doMousej extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				index = group_fj.getIndex();
			}
		}
		
		public class doMousef_btn extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				frame3.setVisible(false);
				
				if(index == 0)
				{
					
					DLabel label = new DLabel(110,100,"����״��");
					DButton btn_fs = new DButton(70,250,"ȷ��");
					DButton btn_ff = new DButton(160,250,"ȡ��");
					
					group_f = new DRadioGroup();
					DRadio radio_fs = new DRadio(100,140,"�ѻ�");
					DRadio radio_ff = new DRadio(100,180,"δ��");
					//radio_fs.setSelect(true);		
					
					group.addControl(radio_fs);
					group.addControl(radio_ff);
					
					index = group_f.getIndex();
					
					frame4 = new DFrame();
					frame4.addControl(label);
					frame4.addControl(btn_fs);
					frame4.addControl(btn_ff);
					frame4.addControl(radio_fs);
					frame4.addControl(radio_ff);
					
					radio_fs.addDMouseListener(new doRadio_fs());
					radio_ff.addDMouseListener(new doRadio_ff());
					btn_fs.addDMouseListener(new doMouse_fs());
					btn_ff.addDMouseListener(new doMouse_ff());
					
					frame4.setSize(300,400);
					frame4.setLocation(500, 100);
					frame4.setVisible(true);
				}
				else
				{
					
					DLabel label_j = new DLabel(110,100,"����״��");
					DButton btn_js = new DButton(70,250,"ȷ��");
					DButton btn_jf = new DButton(160,250,"ȡ��");
					
					group_j = new DRadioGroup();
					DRadio radio_jn = new DRadio(100,140,"����");
					DRadio radio_jy = new DRadio(100,180,"һ��");
					DRadio radio_jc = new DRadio(100,220,"�ϲ�");
					//radio_jn.setSelect(true);		
					
					group.addControl(radio_jn);
					group.addControl(radio_jy);
					group.addControl(radio_jc);
					
					index = group_j.getIndex();
					
					frame5 = new DFrame();
					frame5.addControl(label_j);
					frame5.addControl(btn_js);
					frame5.addControl(btn_jf);
					frame5.addControl(radio_jn);
					frame5.addControl(radio_jy);
					frame5.addControl(radio_jc);
					
					radio_jn.addDMouseListener(new doRadio_jn());
					radio_jy.addDMouseListener(new doRadio_jy());
					radio_jc.addDMouseListener(new doRadio_jc());
					btn_js.addDMouseListener(new doMouse_js());
					btn_jf.addDMouseListener(new doMouse_jf());
					
					frame5.setSize(300,400);
					frame5.setLocation(500, 100);
					frame5.setVisible(true);
				}
				
			}
			
			public class doRadio_jn extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
				    index = group_j.getIndex();
				}
			}
			
			public class doRadio_jy extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					index = group_j.getIndex();
				}
			}
			
			public class doRadio_jc extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					index = group_j.getIndex();
				}
			}
			
			public class doMouse_js extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					if(index == 0)
					{
						health = "����";
					}
					else if(index == 1)
					{
						health = "һ��";
					}
					else if(index == 2)
					{
						health = "�ϲ�";
					}
					
					frame5.setVisible(false);
					frame3.setVisible(true);
					
				}
			}
			
			public class doMouse_jf extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					frame5.setVisible(false);
					frame3.setVisible(true);
				}
			}
				
				
				
			}
			
			public class doRadio_fs extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
				    index = group_f.getIndex();
				}
			}
			
			public class doRadio_ff extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					index = group_f.getIndex();
				}
			}
			
			public class doMouse_fs extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					if(index == 0)
					{
						marriage = "�ѻ�";
					}
					else
					{
						marriage = "δ��";
					}
					frame4.setVisible(false);
					frame3.setVisible(true);
				}
			}
			
			public class doMouse_ff extends DMouseAdapter{
				public void mousePressed(MouseEvent e)
				{
					
					frame4.setVisible(false);
					frame3.setVisible(true);
				}
			}
			
		}
		
		public class doMousej_btn extends DMouseAdapter{
			public void mousePressed(MouseEvent e)
			{
				frame3.setVisible(false);
				frame1.setVisible(true);
			}
		}
	//}
	
    public class doMouse2 extends DMouseAdapter{
		
		public void mousePressed(MouseEvent e)
		{
			//System.out.println("cancel");
			frame1.setVisible(false);
			
			DLabel label_x1 = new DLabel(100,80,"������Ϣ�ܱ�");
			DLabel label_x2 = new DLabel(60,120,"����: ");
			DLabel label_x3 = new DLabel(60,160,"�Ա�: ");
			DLabel label_x4 = new DLabel(60,200,"����: ");
			DLabel label_x5 = new DLabel(60,240,"����: ");
			DLabel label_x6 = new DLabel(60,280,"����: ");
			
			DLabel label_x2_num = new DLabel(100,120,name);
			DLabel label_x3_num = new DLabel(100,160,sex);
			DLabel label_x4_num = new DLabel(100,200,age);
			DLabel label_x5_num = new DLabel(100,240,marriage);
			DLabel label_x6_num = new DLabel(100,280,health);
			
			DButton btn_x1 = new DButton(70,340,"�˳�");
			DButton btn_x2 = new DButton(160,340,"����");
			
			
			frame6 = new DFrame();
		    frame6.addControl(label_x1);
		    frame6.addControl(label_x2);
		    frame6.addControl(label_x3);
		    frame6.addControl(label_x4);
		    frame6.addControl(label_x5);
		    frame6.addControl(label_x6);
		    
		    frame6.addControl(label_x2_num);
		    frame6.addControl(label_x3_num);
		    frame6.addControl(label_x4_num);
		    frame6.addControl(label_x5_num);
		    frame6.addControl(label_x6_num);
		    frame6.addControl(btn_x1);
		    frame6.addControl(btn_x2);
		    
		    btn_x1.addDMouseListener(new doExit());
		    btn_x2.addDMouseListener(new doBack());
		    
			frame6.setSize(300,400);
			frame6.setLocation(500, 100);
			frame6.setVisible(true);
		}
		
		 public class doExit extends DMouseAdapter{
				
				public void mousePressed(MouseEvent e)
				{
					if(frame1 != null)
					  frame1.dispose();
					if(frame2 != null)
					  frame2.dispose();
					if(frame3 != null)
					  frame3.dispose();
					if(frame4 != null)
					  frame4.dispose();
					if(frame5 != null)
					  frame5.dispose();
					if(frame6 != null)
					  frame6.dispose();
				}
		 }
		 
		 public class doBack extends DMouseAdapter{
				
				public void mousePressed(MouseEvent e)
				{
					frame6.dispose();
					frame1.setVisible(true);
				}
		 }
	}
    
    
	
	public static void main(String args[])
	{
		new DApplication();
	}

}
